-
-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v.hull: Dereference after Null check #4524
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
If I understand the static analyser's reasoning correctly: while (edges && edges->delete) { // the check of 'edges' implies it potentially can be NULL
e = edges;
DELETE(edges, e);
}
e = edges->next; // if edges IS in fact null, this will cause crash
... If my understanding of the above is right, it should probably be enough to add a |
i guess using if (edges) will work the same |
In effect they are the same. if (edges) {
e = edges->next;
do {
if (e->delete) {
t = e;
e = e->next;
DELETE(edges, t);
}
else
e = e->next;
} while (e != edges);
} if (!edges)
return;
e = edges->next;
do {
if (e->delete) {
t = e;
e = e->next;
DELETE(edges, t);
}
else
e = e->next;
} while (e != edges); In my opinion the readability and intent of the code is much better with the latter (tip: search for "early return" pattern and "pyramid of doom" anti-pattern). To the root cause of this issue. I managed to reproduce this with Clang's Lines 40 to 43 in 2415894
We have the same problem with CleanFaces() and a similar one with CleanVertices() too. @metzm I'm not quite sure of the implications if Footnotes
|
I think exiting the function early with
is safe because there would be no edges left. |
@nilason Or others, if you are ok with Markus Metz's response and approval, let's merge this. On Monday I'll get it merged if everything is still fine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us address CID: 1207410 and CID: 1207411 too, with this PR.
@metzm Thank you very much for your input!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ShubhamDesai Thanks!
This pull request addresses the issue identified by coverity scan (CID: 1207412)